﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;

namespace BoneSystem.Extensions
{
    public class AngularTag : TagBuilder
    {
        private IList<string> _directives;
        public const string Required = "";

        private IList<string> Directives
        {
            get { return _directives ?? (_directives = new List<string>()); }
            set { _directives = value; }
        }

        public void AddDirective(string directive)
        {
            Directives.Add(directive);
        }
        
        public void RemoveDirective(string directive)
        {
            Directives.Remove(directive);
        }
        public AngularTag(string tagName) : base(tagName)
        {
        }

        public override string ToString()
        {
            var tagRet = new TagBuilder(TagName + "directives");
            
            var tagValue = ToString(TagRenderMode.Normal);
            var strDirectives = Directives.Aggregate("", (current, directive) => current + (" " + directive));
            var strRet = tagValue.Replace(tagRet.ToString(), "" + strDirectives);
            return strRet;
        }
       
        
    }
}
